home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / size / RCS / print68k.c,v < prev    next >
Encoding:
Text File  |  1989-05-17  |  2.9 KB  |  118 lines

  1. head     1.1;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.1
  10. date     89.05.16.23.52.20;  author jhh;  state Exp;
  11. branches ;
  12. next     ;
  13.  
  14.  
  15. desc
  16. @@
  17.  
  18.  
  19.  
  20. 1.1
  21. log
  22. @Initial revision
  23. @
  24. text
  25. @/* 
  26.  * sun23Print.c --
  27.  *
  28.  *    Contains the machine specific routine for printing the size if the
  29.  *    machine is a sun2 or sun3 (they both have the same a.out format).
  30.  *
  31.  * Copyright 1989 Regents of the University of California
  32.  * Permission to use, copy, modify, and distribute this
  33.  * software and its documentation for any purpose and without
  34.  * fee is hereby granted, provided that the above copyright
  35.  * notice appear in all copies.  The University of California
  36.  * makes no representations about the suitability of this
  37.  * software for any purpose.  It is provided "as is" without
  38.  * express or implied warranty.
  39.  */
  40.  
  41. #ifndef lint
  42. static char rcsid[] = "$Header: /sprite/users/jhh/src/size/RCS/sun23Routines.c,v 1.1 89/03/30 16:35:20 jhh Exp Locker: jhh $ SPRITE (Berkeley)";
  43. #endif /* not lint */
  44.  
  45. #include <sun3.md/sys/exec.h>
  46. #include <sun3.md/a.out.h>
  47. #include "size.h"
  48.  
  49.  
  50. /*
  51.  *----------------------------------------------------------------------
  52.  *
  53.  * Print68k --
  54.  *
  55.  *    Prints out the size information for a sun2, sun3 or sun4 a.out file.
  56.  *
  57.  * Results:
  58.  *    SUCCESS if size information was printed, FAILURE otherwise.
  59.  *
  60.  * Side effects:
  61.  *    Stuff is printed.
  62.  *
  63.  *----------------------------------------------------------------------
  64.  */
  65.  
  66. ReturnStatus
  67. Print68k(fp, printName, fileName, printHeadings, bufferSize, buffer)
  68.     FILE    *fp;        /* file that header was read from */
  69.     Boolean    printName;    /* TRUE => print name of file */
  70.     char    *fileName;    /* name of file */
  71.     Boolean    printHeadings;    /* TRUE => print column headings */
  72.     int        bufferSize;    /* size of buffer */
  73.     char    *buffer;    /* buffer containing header */
  74. {
  75.  
  76.     struct exec        *header;
  77.     char        swappedHeader[sizeof(*header) * 2];
  78.     int            swappedSize = sizeof(swappedHeader);
  79.     int            status;
  80.  
  81.     if (bufferSize < sizeof(struct exec)) {
  82.     return FAILURE;
  83.     }
  84.     header = (struct exec *) buffer;
  85.     if (!N_BADMAG(*header)) {
  86.     goto doPrint;
  87.     }
  88.     if (FMT_68K_FORMAT != hostFmt) {
  89.     status = Fmt_Convert("{h2w7}", FMT_68K_FORMAT, &bufferSize, buffer,
  90.             hostFmt, &swappedSize, swappedHeader);
  91.     if (status) {
  92.         fprintf(stderr, "Fmt_Convert returned %d.\n", status);
  93.         return FAILURE;
  94.     }
  95.     header = (struct exec *) swappedHeader;
  96.     if (!N_BADMAG(*header)) {
  97.         goto doPrint;
  98.     }
  99.     }
  100.     return FAILURE;
  101. doPrint:
  102.     if (printHeadings) {
  103.     printf("%-7s %-7s %-7s %-7s %-7s\n", 
  104.            "text", "data", "bss", "dec", "hex");
  105.     }
  106.     printf("%-7d %-7d %-7d %-7d %-7x",
  107.            header->a_text, header->a_data, header->a_bss,
  108.            header->a_text + header->a_data + header->a_bss,
  109.            header->a_text + header->a_data + header->a_bss);
  110.     if (printName) {
  111.     printf("\t%s\n", fileName);
  112.     } else {
  113.     printf("\n");
  114.     }
  115.     return SUCCESS;
  116. }
  117. @
  118.